/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ADT;
import static ADT.Values.*;
/**
 *
 * @author Martin
 */
public class TimeDiffInS extends Scalar implements TimeDiff{
    private final double seconds;
    
    
    @Override public boolean isValid() {return true;}
    @Override public boolean isZero() {return seconds == 0.0;}
    
    public TimeDiffInS(double seconds){this.seconds = seconds;}
    
    @Override public double s(){return seconds;}
    
    @Override public double h(){return seconds * SEC_TO_HOUR;}
    
    @Override public TimeDiff add(TimeDiff time){
        System.out.println("ADD " + this.seconds + " " + time.s() );
        return valueOf(this.seconds + time.s());}
    
    @Override public TimeDiff sub(TimeDiff time){return valueOf(this.seconds - time.s());}
    
    @Override public TimeDiff div(double factor){return valueOf(this.seconds / factor);}
    
    @Override public TimeDiff mul(double factor){return valueOf(this.seconds * factor);}
    
    @Override public double div(TimeDiff time){return this.s() / time.s();}
    
    public static TimeDiff valueOf(double seconds){return new TimeDiffInS(seconds);}
    
    @Override public Speed mul(Acc acc){return speedInMs(seconds * acc.mss());}
    
    @Override public int compareTo(TimeDiff time){return Double.compare(this.s(), time.s());}
    
    @Override public boolean equals(Object o){
        if(this == o) return true;
        if(!(o instanceof TimeDiffInS)) return false;
        return this.compareTo((TimeDiffInS) o) == 0;
    }
    
    public String toString(){
        return String.format("%2, s", this.s());
    }
    public int hashCode(){
        return hashDouble(seconds);
    }
    
}
